package com.cloudwise.monitoring_system.controller.mysqlController;

import com.cloudwise.monitoring_system.entity.MonitorEvent;
import com.cloudwise.monitoring_system.service.mysqlService.MonitorEventService;
import com.cloudwise.monitoring_system.util.Result;
import com.cloudwise.monitoring_system.util.ReturnStatus;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * (MonitorEvent)表控制层
 *
 * @author makejava
 * @since 2021-05-28 11:23:52
 */
@Controller
@RequestMapping("monitorEvent")
@ApiOperation("mysql告警事件控制器")
public class MonitorEventController {
    /**
     * 服务对象
     */
    @Resource
    private MonitorEventService monitorEventService;


    /**
     * 通过实体作为筛选条件查询
     *
     * @return 对象列表
     */
    @ResponseBody
    @GetMapping("queryAll")
    @ApiOperation("查询所有告警事件")
    public Result queryAll(@ApiParam("告警事件信息")MonitorEvent monitorEvent) {
        return new Result(ReturnStatus.SUCCESS.getCode(),
                ReturnStatus.SUCCESS.getMessage(), 0,
                this.monitorEventService.eventQueryAll(monitorEvent));
    }

    /**
     * 新增数据
     *
     * @param monitorEvent 实例对象
     * @return 实例对象
     */
    @ResponseBody
    @PostMapping("insert")
    @ApiOperation("新增一条告警事件")
    public Result insert(@ApiParam("告警事件信息")MonitorEvent monitorEvent) {
        return new Result(ReturnStatus.SUCCESS.getCode(),
                ReturnStatus.SUCCESS.getMessage(), 0,
                this.monitorEventService.insert(monitorEvent));
    }
}
